package com.xuetang9.BBS.dao.impl;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;
import com.xuetang9.BBS.dao.TopictypeDao;
import com.xuetang9.BBS.domain.Topictype;



@Repository
public class TopictypeDaoImpl  implements TopictypeDao{

	
	@Autowired
	private JdbcTemplate jdbcTemplate;
	
	private RowMapper<Topictype> getTopicRowMapper() {
		return new RowMapper<Topictype>() {

			@Override
			public Topictype mapRow(ResultSet resultSet, int arg1) throws SQLException {
				Topictype topictype = new Topictype();
				topictype.setSid(resultSet.getString("sid"));
				topictype.setTitle(resultSet.getString("title"));
				
				return topictype;
			}
		};	
		}
	
	
	public List<Topictype> findTopictypeByTtid() {
		
		String sql = "select * from Topictype";
		RowMapper<Topictype> rm = getTopicRowMapper();
		return jdbcTemplate.query(sql, rm);
		
		

	}


}
